package com.gzck.gzck_verson2.controller;


import com.gzck.gzck_verson2.pojo.GRtuFactor;
import com.gzck.gzck_verson2.service.IGRtuFactorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 采集仪要素中间表 前端控制器
 * </p>
 *
 * @author 任永辉
 * @since 2024-01-27
 */
@RestController
@RequestMapping("/g-rtu-factor")
public class GRtuFactorController {

    @Autowired
    private IGRtuFactorService rtuFactorService;

    // 添加RTU要素信息
    @PostMapping("/add")
    public boolean addRtuFactor(@RequestBody GRtuFactor rtuFactor) {
        return rtuFactorService.save(rtuFactor);
    }

    // 删除RTU要素信息
    @DeleteMapping("/delete/{id}")
    public boolean deleteRtuFactor(@PathVariable Long id) {
        return rtuFactorService.removeById(id);
    }

    // 更新RTU要素信息
    @PutMapping("/update")
    public boolean updateRtuFactor(@RequestBody GRtuFactor rtuFactor) {
        return rtuFactorService.updateById(rtuFactor);
    }

    // 查询单个RTU要素信息
    @GetMapping("/{id}")
    public GRtuFactor getRtuFactor(@PathVariable Long id) {
        return rtuFactorService.getById(id);
    }

    // 查询所有RTU要素信息
    @GetMapping("/all")
    public List<GRtuFactor> getAllRtuFactors() {
        return rtuFactorService.list();
    }
}
